//
//  ExchangeStarView.m
//  Koizora
//
//  Created by dlios on 15-6-8.
//  Copyright (c) 2015年 CupCat. All rights reserved.
//

#import "ExchangeStarView.h"
#import "ExchangeStarCollectionViewCell.h"
#import "HomeView.h"

@implementation ExchangeStarView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.picArr = [NSMutableArray arrayWithObjects:@"白羊座",@"金牛座",@"双子座",@"巨蟹座",@"狮子座",@"处女座",@"天枰座",@"天蝎座",@"射手座",@"摩羯座",@"水瓶座",@"双鱼座", nil];
        self.nameArr = [NSMutableArray arrayWithObjects:@"白羊",@"金牛",@"双子",@"巨蟹",@"狮子",@"处女",@"天枰",@"天蝎",@"射手",@"摩羯",@"水瓶",@"双鱼", nil];
        [self createStarView];
//        self.backgroundColor = [UIColor redColor];
    }
    return self;
}
- (void)createStarView
{
    UICollectionViewFlowLayout *flowlayout = [[UICollectionViewFlowLayout alloc] init];
    flowlayout.itemSize = CGSizeMake(50, 70);
    flowlayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    flowlayout.minimumLineSpacing = 10;
    flowlayout.minimumInteritemSpacing = 10;
    
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.bounds collectionViewLayout:flowlayout];
    collectionView.backgroundColor = [UIColor clearColor];
    collectionView.delegate = self;
    collectionView.dataSource = self;
    [self addSubview:collectionView];
    [collectionView registerClass:[ExchangeStarCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ExchangeStarCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
//    cell.backgroundColor = [UIColor greenColor];
    cell.lable1.font = [UIFont systemFontOfSize:15];
    cell.lable1.text = _picArr [indexPath.row];
    cell.image1.image = [UIImage imageNamed:_nameArr[indexPath.row ]];
   
    return cell;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _picArr.count;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
//    [self jumpToHomeViewControllerWithIndexPath:indexPath HomeViewArr:_picArr];
    
}

@end
